package com.kx.demo.jdk.collection;

import java.util.ArrayList;
import java.util.List;

/**
 * @author kx
 * @date 2020/4/10
 */
public class ArrayListDemo {

    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        List<String> addList = new ArrayList<>();

        addList.add("1");
        addList.add("2");

        list.add("张三");
        list.add("李四");
        list.add("王五");
        list.add(2, "mazi");
//        list.set(1, "王五");
//        System.out.println(list.get(1));
//        list.remove(1);
        System.out.println(list.size());
        System.out.println(list.contains("赵六"));

        for (int i = 0; i < 10 ; i++) {
            list.add("hello_" + i);
        }
//        list.add(null);

        System.out.println(list.remove("hello"));
        list.remove(4);
        System.out.println(list.size());
        System.out.println(list);
        String[] strings = new String[5];
        System.out.println(list.toArray(strings));

        list.addAll(addList);
        System.out.println(list.size());
//        list.addAll(-1, addList);
        System.out.println(list);

        for (String s : list) {
//            list.add("wo");
        }
    }

}
